package 抽象外观模式;

import 抽象外观模式.文件操作.CipherMachine;
import 抽象外观模式.文件操作.FileReader;
import 抽象外观模式.文件操作.FileWriter;
import 抽象外观模式.文件操作.抽象外观类.AbsEncryptFacade;

/**
 * 外观类,继承抽象外观类
 */
public class EncryptFacade extends AbsEncryptFacade {
    private FileReader reader;
    private CipherMachine cipher;
    private FileWriter writer;

    //构造方法
    public EncryptFacade(){
        this.reader=new FileReader();
        this.cipher=new CipherMachine();
        this.writer=new FileWriter();
    }

    /**
     * 重写父类方法
     * @param fileNameSrc
     * @param fileNameDes
     */
   @Override
    public void fileEnctypt(String fileNameSrc,String fileNameDes){
        //1.调用读取文件操作
        String plainStr = reader.read(fileNameSrc);

        //2.加密文件
        String encryptStr = cipher.encrypt(plainStr);

        //3.保存文件
        writer.write(encryptStr, fileNameDes);
    }

}
